package com.fortune.common.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableWebMvc
public class SwaggerConfig {
	@Bean
	public Docket customDocket() {
		return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .select()
        .apis(RequestHandlerSelectors.any())
        .paths(PathSelectors.any())
        .build();
	}

	private ApiInfo apiInfo() {
		StringBuffer descriptioin = new StringBuffer();
		descriptioin.append("生财宝销售管理系统接口文档  Schmes暂时为HTTP ");
		descriptioin.append("<br>");
		descriptioin.append("不以http状态标识业务是否成功  ");
		descriptioin.append("<br>");
		descriptioin.append("所有接口返回的json中的布尔值status标识业务是否成功，业务没成功则msg中是具体的失败信息");
		descriptioin.append("<br>");
        return new ApiInfoBuilder()
                .title("生财宝")
                .description(descriptioin.toString())
                .license("Apache 2.0")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
                .termsOfServiceUrl("")
                .version("20180514")
                .contact(new Contact("","", "940256994@qq.com"))
                .build();
    }
}
